package com.example.news.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.news.R;
import com.example.news.adapter.OneAdapter;
import com.example.news.bean.OneBean;
import com.example.news.iteam.Iteam_oneActivity;

import java.util.ArrayList;

public class KeJiFragment extends Fragment {
    private ListView one_listView;
    private ArrayList<OneBean> list;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_changshang, container, false);
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        list=new ArrayList<>();
        init();
        one_listView=getActivity().findViewById(R.id.changshang_listView);
        one_listView.setAdapter(new OneAdapter(list,getActivity()));
        one_listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent=new Intent(getActivity(), Iteam_oneActivity.class);
                intent.putExtra("i",list.get(i).getIndex()+"");
                intent.putExtra("name",list.get(i).getName());
                startActivity(intent);
                //Toast.makeText(getActivity(), ""+list.get(i).getIndex(),Toast.LENGTH_SHORT).show();
            }
        });
    }
    private void init() {
        list.add(new OneBean(R.drawable.z1,R.drawable.z2,R.drawable.z3,80,"最前线 | 联想手机前掌门人常程加入小米，向林斌汇报"));
        list.add(new OneBean(R.drawable.z6jpg,R.drawable.z7,R.drawable.z8,81,"苹果的新手机？"));
        list.add(new OneBean(R.drawable.z11,R.drawable.z12,R.drawable.z13,82,"取快递都是免费的，快递驿站到底靠什么挣钱？"));
        list.add(new OneBean(R.drawable.z16,R.drawable.z17,R.drawable.z18,83,"未来5G都能干嘛呢，看看这十大应用场景"));
        list.add(new OneBean(R.drawable.z21,R.drawable.z22,R.drawable.z23,84,"华为Mate40Pro去掉浴霸摄像头，果然好看多了"));
        list.add(new OneBean(R.drawable.z25,R.drawable.z26,R.drawable.z27,85,"雷军发飙，小米新机首次降价，这下华为Mate30Pro难受了"));


    }
}
